<!doctype html>
<html lang="en">
<head>
    <title>Code coverage report for src/components/table-tree-column/index.vue</title>
    <meta charset="utf-8" />
    <link rel="stylesheet" href="..\..\..\prettify.css" />
    <link rel="stylesheet" href="..\..\..\base.css" />
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <style type='text/css'>
        .coverage-summary .sorter {
            background-image: url(..\..\..\sort-arrow-sprite.png);
        }
    </style>
</head>
<body>
<div class='wrapper'>
  <div class='pad1'>
    <h1>
      <a href="..\..\..\index.html">All files</a> / <a href="index.html">src/components/table-tree-column</a> index.vue
    </h1>
    <div class='clearfix'>
      <div class='fl pad1y space-right2'>
        <span class="strong">0% </span>
        <span class="quiet">Statements</span>
        <span class='fraction'>0/41</span>
      </div>
      <div class='fl pad1y space-right2'>
        <span class="strong">0% </span>
        <span class="quiet">Branches</span>
        <span class='fraction'>0/31</span>
      </div>
      <div class='fl pad1y space-right2'>
        <span class="strong">0% </span>
        <span class="quiet">Functions</span>
        <span class='fraction'>0/12</span>
      </div>
      <div class='fl pad1y space-right2'>
        <span class="strong">0% </span>
        <span class="quiet">Lines</span>
        <span class='fraction'>0/33</span>
      </div>
    </div>
  </div>
  <div class='status-line low'></div>
<pre><table class="coverage">
<tr><td class="line-count quiet">1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84</td><td class="line-coverage quiet"><span class="cline-any cline-no">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-no">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-no">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-no">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-no">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-no">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-no">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-no">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-no">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-no">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-no">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-no">&nbsp;</span>
<span class="cline-any cline-no">&nbsp;</span>
<span class="cline-any cline-no">&nbsp;</span>
<span class="cline-any cline-no">&nbsp;</span>
<span class="cline-any cline-no">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-no">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-no">&nbsp;</span>
<span class="cline-any cline-no">&nbsp;</span>
<span class="cline-any cline-no">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-no">&nbsp;</span>
<span class="cline-any cline-no">&nbsp;</span>
<span class="cline-any cline-no">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-no">&nbsp;</span>
<span class="cline-any cline-no">&nbsp;</span>
<span class="cline-any cline-no">&nbsp;</span>
<span class="cline-any cline-no">&nbsp;</span>
<span class="cline-any cline-no">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-no">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span></td><td class="text"><pre class="prettyprint lang-js">&lt;<span class="cstat-no" title="statement not covered" >t<span class="fstat-no" title="function not covered" >em</span>plate&gt;</span>
  &lt;el-table-column :prop="prop" v-bind="$attrs"&gt;
    &lt;template slot-scope="scope"&gt;
<span class="cstat-no" title="statement not covered" >      &lt;span @click.prevent="toggleHandle(scope.$index, scope.row)" :style="childStyles(scope.row)"&gt;</span>
        &lt;i :class="iconClasses(scope.row)" :style="iconStyles(scope.row)"&gt;&lt;/i&gt;
        {{ scope.row[prop] }}
      &lt;/span&gt;
    &lt;/template&gt;<span class="cstat-no" title="statement not covered" ></span>
  &lt;/el-table-column&gt;
&lt;/template&gt;<span class="cstat-no" title="statement not covered" ></span>
&nbsp;
&lt;script&gt;<span class="cstat-no" title="statement not covered" ><span class="fstat-no" title="function not covered" ></span></span>
  import isArray from 'lodash/isArray'
<span class="cstat-no" title="statement not covered" >  export default {</span>
    name: 'table-tree-column',
    props: {
      prop: {
        type: String
      },
      treeKey: {
        type: String,
        default: 'id'
      },
      parentKey: {
        type: String,
        default: 'parentId'
      },
      levelKey: {
        type: String,
        default: '_level'
      },
      childKey: {
        type: String,
        default: 'children'
      }
    },
    methods: {
      childStyles (row) {<span class="fstat-no" title="function not covered" ></span>
<span class="cstat-no" title="statement not covered" >        return { 'padding-left': (row[this.levelKey] &gt; 1 ? row[this.levelKey] * 7 : 0) + 'px' }</span>
      },
      iconClasses (row) {<span class="fstat-no" title="function not covered" ></span>
<span class="cstat-no" title="statement not covered" >        return [ !row._expanded ? 'el-icon-caret-right' : 'el-icon-caret-bottom'</span> ]
      },
      iconStyles (row) {<span class="fstat-no" title="function not covered" ></span>
<span class="cstat-no" title="statement not covered" >        return { 'visibility': this.hasChild(row) ? 'visible' : 'hidden' }</span>
      },
      hasChild (row) {<span class="fstat-no" title="function not covered" ></span>
<span class="cstat-no" title="statement not covered" >        return (isArray(row[this.childKey]) &amp;&amp; row[this.childKey].length &gt;= 1) || false</span>
      },
      // 切换处理
      toggleHandle (index, row) {
        if (this.hasChild(r<span class="fstat-no" title="function not covered" >ow)) {</span>
          var data<span class="cstat-no" title="statement not covered" > = th</span>is.$parent.store.states.data.slice(0)
          data[index]._expanded = !data[index]._expanded
<span class="cstat-no" title="statement not covered" >          if (data[index]._expanded) {</span>
            data = <span class="cstat-no" title="statement not covered" >data.splice(0, index + 1).concat(row[thi</span>s.childKey]).concat(data)
<span class="cstat-no" title="statement not covered" >          } else {</span>
<span class="cstat-no" title="statement not covered" >            data = this.removeChildNode(data, row[this.treeKey])</span>
<span class="cstat-no" title="statement not covered" >          }</span>
          this.$parent.store.commit('setData', data)
<span class="cstat-no" title="statement not covered" >          this.$nextTick(() =&gt; {</span>
            this.$parent.doLayout()
<span class="cstat-no" title="statement not covered" >          })</span>
<span class="cstat-no" title="statement not covered" >        }<span class="fstat-no" title="function not covered" ></span></span>
      },<span class="cstat-no" title="statement not covered" ></span>
      // 移除子节点
      removeChildNode (data, parentId) {
        var parentIds = isArray(parentId) ? parentId : [parentId]
        if (parentId.length &lt;= 0) {
          return data
        }<span class="fstat-no" title="function not covered" ></span>
        var ids = []<span class="cstat-no" title="statement not covered" ></span>
<span class="cstat-no" title="statement not covered" >        for (var i = 0; i &lt; data.length; i++) {</span>
<span class="cstat-no" title="statement not covered" >          if (parentI</span>ds.indexOf(data[i][this.parentKey]) !== -1 &amp;&amp; parentIds.indexOf(data[i][this.treeKey]) === -1) {
            ids.push(data.splice(i, 1)[0][this.treeKey])
            i--<span class="cstat-no" title="statement not covered" ></span>
<span class="cstat-no" title="statement not covered" >          }</span>
<span class="cstat-no" title="statement not covered" >        }</span>
        re<span class="cstat-no" title="statement not covered" >turn this.removeChildNode(data, ids)</span>
      }<span class="cstat-no" title="statement not covered" ></span>
    }
  }
&lt;/scri<span class="cstat-no" title="statement not covered" >pt&gt;</span>
&nbsp;</pre></td></tr>
</table></pre>
<div class='push'></div><!-- for sticky footer -->
</div><!-- /wrapper -->
<div class='footer quiet pad2 space-top1 center small'>
  Code coverage
  generated by <a href="https://istanbul.js.org/" target="_blank">istanbul</a> at Thu Sep 20 2018 10:14:21 GMT+0800 (中国标准时间)
</div>
</div>
<script src="..\..\..\prettify.js"></script>
<script>
window.onload = function () {
        if (typeof prettyPrint === 'function') {
            prettyPrint();
        }
};
</script>
<script src="..\..\..\sorter.js"></script>
</body>
</html>
